#尝试读取串口数据
import serial
import time

ser=serial.Serial('/dev/ttyACM0',9600) 
print("listening ttyACM0")
while True:
    a=ser.readline()
    print(a.decode())
    if a!=None:
        f=open('test.log','w',encoding='utf-8')
        f.write(a.decode())
        f.close()

ser.close()
